<?php

/**
 * @bootstrap.php
 * Openquest webPanel bootstrap, initializes the functions on every request.
 *
 */

include_once 'common.php';
include_once 'settings.php';
include_once 'mod_postfix.php';

/* TODO:
 * -  opens a configuration file, and gather the available modules to register them
 */

error_log("");
error_log("»»»»»»»» webPanel's log [bootstrap] ««««««««");
   
/*
 * This creates a server and sets a handle for the server in the variable $xmlrpc_server
 */
$xmlrpc_server = xmlrpc_server_create();

/*
 * Register PHP functions as an XML-RPC method.
 */
xmlrpc_server_register_method($xmlrpc_server, "mail.listDomains", "processRequest");
xmlrpc_server_register_method($xmlrpc_server, "mail.listDomainUsers", "processRequest");
xmlrpc_server_register_method($xmlrpc_server, "mail.newDomain", "processRequest");
xmlrpc_server_register_method($xmlrpc_server, "mail.newUser", "processRequest");
xmlrpc_server_register_method($xmlrpc_server, "mail.delDomain", "processRequest");
xmlrpc_server_register_method($xmlrpc_server, "mail.setPass", "processRequest");
xmlrpc_server_register_method($xmlrpc_server, "mail.delUser", "processRequest");

/*
 * When an XML-RPC request is sent to this script, it can be found in the raw
 * post data.
 */
$request_xml = file_get_contents('php://input');

/*
 * Send request to server and get response
 */ 
$response = xmlrpc_server_call_method($xmlrpc_server, $request_xml, '');

/*
 * Print the response for the client to read.
 */
print $response;

/*
 * Free resources
 */
xmlrpc_server_destroy($xmlrpc_server);

?>
